/**
* 选择的工具类
*/
const utilSelect = {
  /**
   * @Description：选择单位-单个
   * @Date 2023-10-24
   * @param confirm确认回调函数
   */
  unit(confirm) {
    let home = global.vue.$children[0].$children[0]
    home.selectWrapper.unit.subtitle = '所有单位'
    home.selectWrapper.unit.propUserParam = {}
    home.selectWrapper.unit.queryWrapper = null
    home.$refs.tableDrawerUnit.show((row, refName) => {
      if (confirm) {
        confirm(row, refName)
      }
    }, false)
  },
  /**
   * @Description：供应商选择-单个
   * @Date 2023-10-24
   * @param confirm确认回调函数
   */
  sp(confirm, hospitalId) {
    let home = global.vue.$children[0].$children[0]
    home.selectWrapper.sp.propUserParam = {
      hospitalId: hospitalId
    }

    let subtitle = ''
    if (global.strings.isNotBlank(hospitalId)) {
      subtitle += '该医院已供货供应商列表'
    }
    home.selectWrapper.sp.subtitle = subtitle
    home.selectWrapper.sp.queryWrapper = null
    home.$refs.tableDrawerSp.show((row, refName) => {
      if (confirm) {
        confirm(row, refName)
      }
    }, false)
  },
  /**
   * @Description：医院仓库选择-单个
   * @Date 2023-10-24
   * @param confirm确认回调函数
   */
  hospitalWarehouse(confirm, hospitalId) {
    let home = global.vue.$children[0].$children[0]
    home.selectWrapper.hospitalWarehouse.propUserParam = {}

    let subtitle = ''
    let wrapper = global.$newWrapper()
    if (global.strings.isNotBlank(hospitalId)) {
      subtitle += '该医院相关仓库'
      wrapper.eq('hospitalId', hospitalId)
    }
    home.selectWrapper.hospitalWarehouse.subtitle = subtitle
    home.selectWrapper.hospitalWarehouse.queryWrapper = wrapper
    home.$refs.tableDrawerHospitalWarehouse.show((row, refName) => {
      if (confirm) {
        confirm(row, refName)
      }
    }, false)
  },
  /**
   * @Description：医院商品选择-多个
   * @Date 2023-10-24
   * @param confirm确认回调函数
   * @param hospitalId 医院id
   * @param spId 供应商id
   * @param flagOmoc 是否一物一码/标签管理
   * @param flagConsignment 寄售
   * @param materialTypeCode 商品类型
   * @param inactive  1：启用 0停用
   */
  hospitalMaterialMore(confirm, hospitalId,spId,flagOmoc,flagConsignment,materialTypeCode, inactive = 1) {
    let home = global.vue.$children[0].$children[0]
    home.selectWrapper.hospitalMaterial.propUserParam = {}

    let subtitle = ''
    let wrapper = global.$newWrapper()
    if (global.strings.isNotBlank(hospitalId)) {
      subtitle += '<span class="span-msg">已供货该医院</span>'
      wrapper.eq('hospitalId', hospitalId)
    }
    if (global.strings.isNotBlank(spId)) {
      wrapper.eq('supplierId', spId)
      subtitle += '<span class="span-msg">该供应商</span>'
    }
    if (global.strings.isNotBlank(flagOmoc)) {
      wrapper.eq('is_one_thing_one_yard', flagOmoc)
      subtitle += global.utils.getBooleanLabel(flagOmoc,'标签管理', '非标签管理',true)
    }
    if (global.strings.isNotBlank(flagConsignment)) {
      wrapper.eq('is_consignment', flagConsignment)
      subtitle += global.utils.getBooleanLabel(flagConsignment,'购销', '代销',true)
    }
    if (global.strings.isNotBlank(inactive)) {
      wrapper.eq('inactive', inactive)
      subtitle += global.utils.getBooleanLabel(inactive,'启用', '停用',true)
    }

    if (global.strings.isNotBlank(materialTypeCode)) {
      wrapper.eq('materialTypeCode', materialTypeCode)
      subtitle+= ',' + global.utils.getDictLabel(materialTypeCode, global.constCommon.dictType.baseMatrType, '', true)
    }

    home.selectWrapper.hospitalMaterial.subtitle = subtitle
    home.selectWrapper.hospitalMaterial.queryWrapper = wrapper
    home.$refs.tableDrawerHospitalMaterial.show((row, refName) => {
      if (confirm) {
        confirm(row, refName)
      }
    }, true)
  },
  /**
   * @Description：系统日志
   * @Date 2023-10-24
   * @param busId 业务主键
   */
  sysLog(busId) {
    let home = global.vue.$children[0].$children[0]
    let wrapper = global.$newWrapper()
    wrapper.eq('busId',busId)
    home.$refs.customDrawerSyslog.show()
    home.$refs.dataViewSyslog.setQueryWrapper(wrapper)
  },
  /**
   * @Description：用户列表
   * @Date 2023-10-24
   * @param roleIdNotList  需要排除的角色
   */
  userListMore(confirm, roleIdNotList,inactive = 1) {
    let home = global.vue.$children[0].$children[0]
    let wrapper = global.$newWrapper()
    let subtitle = ''
    if (roleIdNotList) {
      subtitle += '<span class="span-msg">未添加该角色</span>'
    }
    if (global.strings.isNotBlank(inactive)) {
      wrapper.eq('inactive', inactive)
      subtitle += global.utils.getBooleanLabel(inactive,'启用', '停用',true)
    }

    home.selectWrapper.userListMore.queryWrapper = wrapper
    home.selectWrapper.userListMore.subtitle = subtitle
    home.$refs.tableDrawerUserListMore.show((row, refName) => {
      if (confirm) {
        confirm(row, refName)
      }
    }, true)
  },

  /**
   * @Description：新增并选择窗口 厂商
   * @Date 2024-04-17
   * @param matrId 商品id
   * @param  hisCode  商品his编码  'base_mfg', 'base/mfg/detail.vue'
   */
  openSelectCreateFormMfg(afterSave) {
    let home = global.vue.$children[0].$children[0]
    home.openSelectCreateForm('厂商', 'manufacturers_crud','base/mfg/detail.vue', afterSave)
  }
}

setTimeout(() => {
}, 5000)

export default utilSelect
